<template>
	<view>
		<view class="form-list">
			<view class="form-item required">
				<text class="label">活动名称</text>
				<input v-model="state.change_detail" placeholder="活动名称" placeholder-class="placeholder-style" />
			</view>
			<view class="form-item required">
				<text class="label">活动分数</text>
				<input type="number" v-model="state.jackpoint" placeholder="请输活动分数"
					placeholder-class="placeholder-style" />
			</view>
			<view class="form-item required">
				<text class="label">参加人员</text>
				<input v-model="state.person_name" placeholder="参与人员名称"
					placeholder-class="placeholder-style" />
			</view>

			<view class="addWallt" @click="addScore()">
				添加积分
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		reactive,
		onMounted
	} from "vue";
	import {
		onShow
	} from '@dcloudio/uni-app';
	import {
		request,
		getOptionLabel
	} from "../../js/util.js";

	const state = reactive({
		change_detail: "",
		jackpoint: 0,
	});
	const addScore = async () => {
		// let id = 
		let submitData = {
			user_id: uni.getStorageSync('searchUser'),
			person_name: state.person_name,
			change_detail: state.change_detail,
			jackpoint: state.jackpoint,
			time: new Date().getTime()
		}
		const data = await request("addJackpoint", submitData);
		console.log("addJackpoint", data)
		if (data.result) {
			uni.showToast({
				title: "新增成功",
				icon: "success",
			});
		} else {
			uni.showToast({
				title: "新增失败",
				icon: "error",
			});
		}
	}
	// 获取用户列表
	const getUserList = async () => {
		// 调用接口获取用户列表
		let submitData = {
			condition: {
				status: 1,
				user_id: uni.getStorageSync('searchUser'),
			},
		};
		const res = await request("selectUser", submitData);
		console.log('res', res)
		if (res.status) {
			state.userList = res.result
		} else {
			uni.showToast({
				title: res.data.msg || "获取家庭成员失败",
				icon: "none",
			});
		}
	};
</script>

<style lang="scss">
	.form-list {
		padding: 20rpx;
	}

	.form-item {
		display: flex;
		align-items: center;
		padding: 30rpx 0;
		border-bottom: 1rpx solid #eee;

		&:last-child {
			border-bottom: none;
		}

		.label {
			width: 160rpx;
			font-size: 28rpx;
			color: #333;
			flex-shrink: 0;

			&::before {
				content: '*';
				color: #ff5555;
				margin-right: 4rpx;
			}
		}

		input {
			flex: 1;
			font-size: 28rpx;
		}

		.picker-value {
			flex: 1;
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 28rpx;

			.arrow {
				color: #999;
				margin-left: 10rpx;
			}
		}
	}

	// 活动标题和详情的特殊样式
	// .form-item:first-child{
	// 	display: block;

	// 	input,
	// 	textarea {
	// 		width: 100%;
	// 		margin-top: 20rpx;
	// 	}

	// 	.count {
	// 		text-align: end;
	// 		color: #999;
	// 	}
	// }

	.addWallt {
		width: 80%;
		margin: 20rpx auto;
		background-color: greenyellow;
		border-radius: 40rpx;
		text-align: center;
		padding: 20rpx;
	}
</style>